<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>MyHomework 查看作业</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="css/styles.css">
		<script src="javascript/jquery-1.6.2.min.js" type="text/javascript"></script>
		<script src="javascript/myhomework.js" type="text/javascript"></script>
		<script src="javascript/slideToggle.js" type="text/javascript"></script>
		<script src="javascript/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
	</head>

	<body>
		<h1 id="login-title">MyHomework</h1>
		<div id="navbox">
		<span class="currentuser"><a href="logout">退出</a></span>
		<span class="currentuser">
				<%
				HttpSession seeion;
				String role = session.getAttribute("role").toString();
				int userId = (Integer) session.getAttribute("user");
				out.println(role + "(" + userId + ")");
			%>
		</span>
    	<ul>
			<li><a href="index">首页</a></li>
			<% 
    		if (role.equals("teacher")|| role.equals("ta")){
   			%> 
    
    		<li><a href="addUser.jsp">添加用户</a></li>
    
    		<% } 
    		%>
			<li><a href="group.action">小组</a></li>
    		<li class="current"><a href="homework!showHomework.action">作业</a></li>
   		 	<li><a href="homeworkResult!showHomeworkResults.action">作业结果</a></li>
   		 	<s:if test="role.equals('student')">
    		<li><a href="review.action">组长评审</a></li>
    		</s:if>
    		<s:elseif test="role.equals('ta') || role.equals('teacher')">
    		<li><a href="review.action">评分</a></li>
    		</s:elseif>
   		</ul>	
   		<br />
   		</div><br />
   		
		<s:if test="role.equals('ta')||role.equals('teacher')">
			<input type="button" id="addHomeworkBtn" value="发布作业" />
			<div id="adhw">
			<div id="addHomeworkFiled" style="display: none">
				标题：
				<input name="title" id="title" type="text" />
				<br />
				内容：
				<textarea name="content" id="_content" cols="50" rows="5"></textarea>
				<br />
				截止日期：
				<input name="deadline" id="deadline" type="text">
					(yyyy-MM-dd hh:mm:ss)</input>
				<br />
				<input type="button" id="addHomework" value="发布" />
				<input type="button" id="cancelAddHomework" value="取消" />
				<br />
			</div>
			</div>
		</s:if>
		

		<p id="introduction">所有作业：</p>
		<s:if test="homeworkInfos.size()>0">
			<s:iterator value="homeworkInfos" var="h">
			<div id="eachHomework" class="eachHomeworkView">
			<div id="content">
			<div>
	  		<label>名称: </label><s:property value="#h.homework.title" />
				<br />
	  		<label>内容: </label>
	  		<s:if test="#h.homework.content.length() < 18">
	  		<s:property value="#h.homework.content" />
	  		</s:if>
	  		<s:else>
	  		<s:property value="#h.homework.content.substring(0,17)"/><span class="hideabstruct" style="display:none"><s:property value="#h.homework.content.substring(17)" /></span>
	  		<img class="moreabstact" title="展开全文" src="img/showall.png"></img>
	  		</s:else>
				<br />
	  		<label>修改时间: </label> <s:date name="#h.homework.createDate" format="yyyy-MM-dd hh:mm:ss" />
				<br />
	  		<label>截止时间: </label><s:date name="#h.homework.deadline" format="yyyy-MM-dd hh:mm:ss" /><br />
	  		<s:if test="role.equals('student')">
	  			<label>提交状态: </label>
	  			<s:if test="#h.submit==true">
	  			  已交
	  			</s:if>
	  			<s:else>未交</s:else>
	  		</s:if>
	  		</div>
	  		<div id="selection">
				<s:if test="currentDate<#h.homework.deadline&&(role.equals('ta')||role.equals('teacher'))">
					<a href="homework!updateHomework?id=<s:property value="#h.homework.id" />"><input type="button" class="groupButton" value="修改" /></a>
					<br />
				</s:if>
			</div>
				<s:elseif test="currentDate<#h.homework.deadline && role.equals('student')">
					<s:form action="homeworkResult.action" enctype="multipart/form-data" method="post">
						<input  type="hidden" name="homeworkid" value="<s:property value="#h.homework.id" />" />
						<s:file class="upload" name="upload"  />
						<s:submit class="upload" value="上传" /><br />
					</s:form>
				</s:elseif>
				</div>
				</div>
			</s:iterator>
		</s:if>
		<s:else>暂时没有作业！</s:else>
		
	</body>
</html>
